home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Source ƒ / egrep-1.5 / grep-src / grep.man.text < prev    next >
Encoding:
Text File  |  1991-08-23  |  8.1 KB  |  222 lines

  1.  
  2.  
  3.  
  4. GREP(1)                  USER COMMANDS                    GREP(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      grep, egrep - print lines matching a regular expression
  10.  
  11. SYNOPSIS
  12.      grep [ -CVbchilnsvwx ] [ -num ] [ -AB num ] [ [ -e ] expr  |
  13.      -f file ] [ files ... ]
  14.  
  15. DESCRIPTION
  16.      Grep searches the files listed in the arguments (or standard
  17.      input  if  no  files are given) for all lines that contain a
  18.      match for the given expr.  If  any  lines  match,  they  are
  19.      printed.
  20.  
  21.      Also, if any matches were  found,  grep  will  exit  with  a
  22.      status  of 0, but if no matches were found it will exit with
  23.      a status of 1.  This is useful for  building  shell  scripts
  24.      that use grep as a condition for, for example, the if state-
  25.      ment.
  26.  
  27.      When invoked as egrep the syntax of  the  expr  is  slightly
  28.      different; See below.
  29.  
  30. REGULAR EXPRESSIONS
  31.           (grep)    (egrep)   (explanation)
  32.  
  33.           c         c         a   single   (non-meta)   character
  34.                               matches itself.
  35.  
  36.           .         .         matches any single character except
  37.                               newline.
  38.  
  39.           \?        ?         postfix operator;  preceeding  item
  40.                               is optional.
  41.  
  42.           *         *         postfix operator; preceeding item 0
  43.                               or more times.
  44.  
  45.           \+        +         postfix operator; preceeding item 1
  46.                               or more times.
  47.  
  48.           \|        |         infix  operator;   matches   either
  49.                               argument.
  50.  
  51.           ^         ^         matches the  empty  string  at  the
  52.                               beginning of a line.
  53.  
  54.           $         $         matches the empty string at the end
  55.                               of a line.
  56.  
  57.           \<        \<        matches the  empty  string  at  the
  58.                               beginning of a word.
  59.  
  60.           \>        \>        matches the empty string at the end
  61.                               of a word.
  62.  
  63.           [chars]   [chars]   match any character  in  the  given
  64.                               class; if the first character after
  65.                               [ is ^, match any character not  in
  66.                               the given class; a range of charac-
  67.                               ters   may    be    specified    by
  68.                               first-last; for example, \W (below)
  69.                               is   equivalent   to   the    class
  70.                               [^A-Za-z0-9]
  71.  
  72.           \( \)     ( )       parentheses are  used  to  override
  73.                               operator precedence.
  74.  
  75.           \digit    \digit    \n matches a  repeat  of  the  text
  76.                               matched  earlier  in  the regexp by
  77.                               the subexpression  inside  the  nth
  78.                               opening parenthesis.
  79.  
  80.           \         \         any special character may  be  pre-
  81.                               ceded  by  a  backslash to match it
  82.                               literally.
  83.  
  84.           (the following are for compatibility with GNU Emacs)
  85.  
  86.           \b        \b        matches the  empty  string  at  the
  87.                               edge of a word.
  88.  
  89.           \B        \B        matches the empty string if not  at
  90.                               the edge of a word.
  91.  
  92.           \w        \w        matches word-constituent characters
  93.                               (letters & digits).
  94.  
  95.           \W        \W        matches  characters  that  are  not
  96.                               word-constituent.
  97.  
  98.      Operator precedence is (highest to lowest) ?, *, and +, con-
  99.      catenation, and finally |.  All other constructs are syntac-
  100.      tically identical  to  normal  characters.   For  the  truly
  101.      interested,  the  file  dfa.c describes (and implements) the
  102.      exact grammar understood by the parser.
  103.  
  104. OPTIONS
  105.      -A num
  106.           print <num> lines of context after every matching line
  107.  
  108.      -B num
  109.           print num lines of context before every matching line
  110.  
  111.      -C   print 2 lines of context on each side of every match
  112.  
  113.      -num print num lines of context on each side of every match
  114.  
  115.      -V   print the version number on the diagnostic output
  116.  
  117.      -b   print every match preceded by its byte offset
  118.  
  119.      -c   print a total count of matching lines only
  120.  
  121.      -e expr
  122.           search for expr; useful if expr begins with -
  123.  
  124.      -f file
  125.           search for the expression contained in file
  126.  
  127.      -h   don't display filenames on matches
  128.  
  129.      -i   ignore case difference when comparing strings
  130.  
  131.      -l   list files containing matches only
  132.  
  133.      -n   print each match preceded by its line number
  134.  
  135.      -s   run silently producing no output except error messages
  136.  
  137.      -v   print only lines that contain no matches for the <expr>
  138.  
  139.      -w   print only lines where the match is a complete word
  140.  
  141.      -x   print only lines where the match is a whole line
  142.  
  143. SEE ALSO
  144.      emacs(1), ed(1), sh(1), GNU Emacs Manual
  145.  
  146. INCOMPATIBILITIES
  147.      The following incompatibilities with UNIX grep exist:
  148.  
  149.           The context-dependent meaning of *  is  not  quite  the
  150.           same (grep only).
  151.  
  152.           -b prints a byte offset instead of a block offset.
  153.  
  154.           The {m,n} construct of System  V  grep  is  not  imple-
  155.           mented.
  156.  
  157. BUGS
  158.      GNU e?grep  has  been  thoroughly  debugged  and  tested  by
  159.      several  people  over  a  period of several months; we think
  160.      it's a reliable beast or we wouldn't distribute it.   If  by
  161.      some  fluke  of  the  universe  you  discover  a bug, send a
  162.      detailed description  (including  options,  regular  expres-
  163.      sions, and a copy of an input file that can reproduce it) to
  164.      me, mike@wheaties.ai.mit.edu.
  165.  
  166.      There is also a newsgroup, gnu.utils.bug, for reporting  FSF
  167.      utility programs' bugs and fixes; but before reporting some-
  168.      thing as a bug, please try to be sure that it  really  is  a
  169.      bug,  not a misunderstanding or a deliberate feature.  Also,
  170.      include the version number of the utility  program  you  are
  171.      running in every bug report that you send in.  Please do not
  172.      send anything but bug reports to this newsgroup.
  173.  
  174.      But do not ask  the group about this Mac version;  they have 
  175.      nothing to do with it.
  176.  
  177. AVAILABILITY
  178.      GNU grep is free; anyone may redistribute copies of grep  to
  179.      anyone  under  the  terms  stated  in the GNU General Public
  180.      License, a copy of which may be found in each  copy  of  GNU
  181.      Emacs.   See also the comment at the beginning of the source
  182.      code file grep.c.
  183.  
  184.      Copies of GNU grep may sometimes be received  packaged  with
  185.      distributions  of  Unix systems, but it is never included in
  186.      the scope of  any  license  covering  those  systems.   Such
  187.      inclusion  violates  the terms on which distribution is per-
  188.      mitted.  In fact, the primary purpose of the General  Public
  189.      License  is to prohibit anyone from attaching any other res-
  190.      trictions to redistribution of  any  of  the  Free  Software
  191.      Foundation programs.
  192.  
  193. AUTHORS
  194.      Mike Haertel wrote the deterministic  regexp  code  and  the
  195.      bulk of the program.
  196.  
  197.      James A. Woods is  responsible  for  the  hybridized  search
  198.      strategy  of using Boyer-Moore-Gosper fixed-string search as
  199.      a filter before calling the general regexp matcher.
  200.  
  201.      Arthur David Olson contributed code that finds fixed strings
  202.      for  the  aforementioned  BMG  search  for  a large class of
  203.      regexps.
  204.  
  205.      Richard Stallman wrote the backtracking regexp matcher  that
  206.      is  used  for  \digit  backreferences, as well as the getopt
  207.      that is provided for 4.2BSD sites.  The backtracking matcher
  208.      was originally written for GNU Emacs.
  209.  
  210.      D. A. Gwyn wrote the C alloca emulation that is provided  so
  211.      System  V  machines  can  run this program.  (Alloca is used
  212.      only by RMS' backtracking matcher, and then only rarely,  so
  213.      there  is  no  loss  if  your  machine doesn't have a "real"
  214.      alloca.)
  215.  
  216.      Scott Anderson and Henry  Spencer  designed  the  regression
  217.      tests used in the "regress" script.
  218.  
  219.      Paul Placeway wrote the  original  version  of  this  manual
  220.      page.
  221.  
  222.